package com.lixin.smartclassroom.ui.home.adapter

import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color
import android.graphics.Matrix
import android.media.ExifInterface
import android.media.MediaMetadataRetriever
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout.HORIZONTAL
import android.widget.SeekBar
import android.widget.SeekBar.OnSeekBarChangeListener
import android.widget.TextView
import androidx.core.widget.doAfterTextChanged
import androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.drake.brv.BindingAdapter
import com.drake.brv.layoutmanager.HoverGridLayoutManager
import com.drake.brv.utils.grid
import com.drake.brv.utils.linear
import com.drake.brv.utils.setup
import com.drake.channel.sendEvent
import com.drake.net.utils.scopeNetLife
import com.drake.tooltip.toast
import com.lixin.smartclassroom.R
import com.lixin.smartclassroom.api.addLikeComment
import com.lixin.smartclassroom.api.chuliweiqiandao
import com.lixin.smartclassroom.api.clickrenwu
import com.lixin.smartclassroom.api.delteacherorstudent
import com.lixin.smartclassroom.bean.BiaoQianBean
import com.lixin.smartclassroom.bean.DataListBean
import com.lixin.smartclassroom.bean.EvaluationQuestionsDto
import com.lixin.smartclassroom.bean.Options
import com.lixin.smartclassroom.bean.PaperItem
import com.lixin.smartclassroom.bean.RoleBean
import com.lixin.smartclassroom.bean.ScoreDto
import com.lixin.smartclassroom.bean.ScoreSetEvent
import com.lixin.smartclassroom.bean.Small
import com.lixin.smartclassroom.bean.StudentBean
import com.lixin.smartclassroom.bean.TeacherBean
import com.lixin.smartclassroom.bean.TopicListDto
import com.lixin.smartclassroom.bean.WeiduBean
import com.lixin.smartclassroom.common.commonEditTextDialog
import com.lixin.smartclassroom.common.saveSuccessDialog
import com.lixin.smartclassroom.common.selectGroupMemberDialog
import com.lixin.smartclassroom.common.setChapterDialog
import com.lixin.smartclassroom.common.sourceSetDialog
import com.lixin.smartclassroom.databinding.ItemAbnormalTotalBinding
import com.lixin.smartclassroom.databinding.ItemAnswerBinding
import com.lixin.smartclassroom.databinding.ItemBindStudentBinding
import com.lixin.smartclassroom.databinding.ItemChoiceQuestionAnswerBinding
import com.lixin.smartclassroom.databinding.ItemClassNoticeBinding
import com.lixin.smartclassroom.databinding.ItemClassStudentBinding
import com.lixin.smartclassroom.databinding.ItemClassTeacherBinding
import com.lixin.smartclassroom.databinding.ItemClassVenueTaskBinding
import com.lixin.smartclassroom.databinding.ItemCommentBinding
import com.lixin.smartclassroom.databinding.ItemCourseChapterBinding
import com.lixin.smartclassroom.databinding.ItemCourseChapterExercisesBinding
import com.lixin.smartclassroom.databinding.ItemCourseClassBinding
import com.lixin.smartclassroom.databinding.ItemCourseMyAttendBinding
import com.lixin.smartclassroom.databinding.ItemCourseMyCreateBinding
import com.lixin.smartclassroom.databinding.ItemCourseRecommendBinding
import com.lixin.smartclassroom.databinding.ItemCourseReviewBinding
import com.lixin.smartclassroom.databinding.ItemCourseReviewClassStudentBinding
import com.lixin.smartclassroom.databinding.ItemCourseType1Binding
import com.lixin.smartclassroom.databinding.ItemCourseType2Binding
import com.lixin.smartclassroom.databinding.ItemCourseType3Binding
import com.lixin.smartclassroom.databinding.ItemDatabaseBinding
import com.lixin.smartclassroom.databinding.ItemDatabaseDetailBinding
import com.lixin.smartclassroom.databinding.ItemEvaluateQuestionWeiduBinding
import com.lixin.smartclassroom.databinding.ItemExcitingMomentsBinding
import com.lixin.smartclassroom.databinding.ItemExcitingMomentsListBinding
import com.lixin.smartclassroom.databinding.ItemExcitingMomentsManagerBinding
import com.lixin.smartclassroom.databinding.ItemGridCustomBinding
import com.lixin.smartclassroom.databinding.ItemGroupScoreBinding
import com.lixin.smartclassroom.databinding.ItemImgBinding
import com.lixin.smartclassroom.databinding.ItemMessageBinding
import com.lixin.smartclassroom.databinding.ItemMessageBoardHistoryBinding
import com.lixin.smartclassroom.databinding.ItemMessageTaskBinding
import com.lixin.smartclassroom.databinding.ItemMessageTeacherSendBinding
import com.lixin.smartclassroom.databinding.ItemMyClassBinding
import com.lixin.smartclassroom.databinding.ItemMyClassTeacherBinding
import com.lixin.smartclassroom.databinding.ItemPaperOptionBinding
import com.lixin.smartclassroom.databinding.ItemQuestionnaireBinding
import com.lixin.smartclassroom.databinding.ItemQuestionnaireDetailBinding
import com.lixin.smartclassroom.databinding.ItemRecentAttendBinding
import com.lixin.smartclassroom.databinding.ItemRecyclerDialogBinding
import com.lixin.smartclassroom.databinding.ItemRoleSelectBinding
import com.lixin.smartclassroom.databinding.ItemScoreSetBinding
import com.lixin.smartclassroom.databinding.ItemSelectGroupMemberBinding
import com.lixin.smartclassroom.databinding.ItemSetGroupBinding
import com.lixin.smartclassroom.databinding.ItemStudentReadBinding
import com.lixin.smartclassroom.databinding.ItemSystemMessageBinding
import com.lixin.smartclassroom.databinding.ItemTab3RecyclerBinding
import com.lixin.smartclassroom.databinding.ItemTaskScoreBinding
import com.lixin.smartclassroom.databinding.ItemTeacherLeaderBinding
import com.lixin.smartclassroom.databinding.ItemTextBinding
import com.lixin.smartclassroom.databinding.ItemWeiduBinding
import com.lixin.smartclassroom.databinding.ItemYanxueCenterBinding
import com.lixin.smartclassroom.ext.allGroupIdList
import com.lixin.smartclassroom.ext.chapterPosition
import com.lixin.smartclassroom.ext.child_id
import com.lixin.smartclassroom.ext.child_name
import com.lixin.smartclassroom.ext.user_role
import com.lixin.smartclassroom.ui.WebHtmlActivity
import com.lixin.smartclassroom.ui.home.tab1.activity.AbNormalTotalAct
import com.lixin.smartclassroom.ui.home.tab1.activity.CommentDetailAct
import com.lixin.smartclassroom.ui.home.tab1.activity.CourseDetailAct
import com.lixin.smartclassroom.ui.home.tab1.activity.ExcitingMomentDetailAct
import com.lixin.smartclassroom.ui.home.tab1.activity.InviteMessageAct
import com.lixin.smartclassroom.ui.home.tab1.activity.MessageDetailAct
import com.lixin.smartclassroom.ui.home.tab1.activity.TeacherSendMessageAct
import com.lixin.smartclassroom.ui.home.tab2.activity.AddSmallChapterAct
import com.lixin.smartclassroom.ui.home.tab2.activity.CourseReviewAct
import com.lixin.smartclassroom.ui.home.tab2.activity.PracticeDetailAct
import com.lixin.smartclassroom.ui.home.tab2.activity.SmartCourseDetailAct
import com.lixin.smartclassroom.ui.home.tab2.activity.TaskDetailAct
import com.lixin.smartclassroom.ui.home.tab4.activity.YanXueDetailAct
import com.lixin.smartclassroom.ui.home.tab5.activity.ClassStudentAct
import com.lixin.smartclassroom.ui.home.tab5.activity.DatabaseDetailPreviewAct
import com.lixin.smartclassroom.ui.home.tab5.activity.MyClassAct
import com.lixin.smartclassroom.ui.home.tab5.activity.QuestionnaireDetailAct
import com.lixin.smartclassroom.ui.home.tab5.activity.ReleaseNoticeAct
import com.lixin.smartclassroom.utils.NumberFormatUtil
import com.lixinkeji.extension.GSON
import com.lixinkeji.extension.applyVisible
import com.lixinkeji.extension.bottomDialog
import com.lixinkeji.extension.dp2px
import com.lixinkeji.extension.finish
import com.lixinkeji.extension.gone
import com.lixinkeji.extension.loadCircle
import com.lixinkeji.extension.loadRound
import com.lixinkeji.extension.onClick
import com.lixinkeji.extension.pictureSelect
import com.lixinkeji.extension.preview
import com.lixinkeji.extension.round
import com.lixinkeji.extension.screenWidth
import com.lixinkeji.extension.setRoundRectBg
import com.lixinkeji.extension.start
import com.lixinkeji.extension.visible
import com.lixinkeji.utils.DateUtils
import com.lixinkeji.utils.FileUtil
import com.lixinkeji.utils.GlideEngine
import com.lixinkeji.widget.GridImageView
import com.lixinkeji.widget.XBaseAdapter
import com.luck.picture.lib.basic.PictureSelector
import com.luck.picture.lib.entity.LocalMedia
import com.luck.picture.lib.interfaces.OnExternalPreviewEventListener
import com.lwb.radarchart.RadarChartView
import com.ypx.imagepicker.bean.ImageItem
import java.math.BigDecimal

/**
 * Description
 * Author: lwc
 * Date:2023/12/5 13:32
 */

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.selectRole(): BindingAdapter {
    return linear().setup {
        addType<RoleBean>(R.layout.item_role_select)
        singleMode = true
        onBind {
            val bean = getModel<RoleBean>()
            getBinding<ItemRoleSelectBinding>().apply {
                Glide.with(context).load(bean.roleImg).into(img)
                tvRole.text = bean.roleName
                btnSelect.isSelected = bean.selectFlag
                if (bean.selectFlag) {
                    rl.background = context.getDrawable(R.drawable.shape_border_main_10dp)
                } else {
                    rl.background = context.getDrawable(R.drawable.shape_rect_white_10dp)
                }
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.excitingMoment(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_exciting_moments)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemExcitingMomentsBinding>().apply {
                img.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                tvContent.text = bean.title
                if (bean.seecount.toString().isEmpty()) {
                    bean.seecount = "0"
                }
                tvLookNum.text = bean.seecount.toString() + "位同学看过"
                tvTime.text = "活动时间：" + bean.createdate?.substring(0, 10)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.excitingMomentList(): BindingAdapter {
    return grid(2).setup {
        addType<DataListBean>(R.layout.item_exciting_moments_list)
        singleMode = true
        (layoutManager as HoverGridLayoutManager).spanSizeLookup = object : SpanSizeLookup() {
            override fun getSpanSize(position: Int): Int {
                return when (position) {
                    0 -> 2
                    else -> 1
                }
            }
        }
        onBind {
            val bean = getModel<DataListBean>()

            getBinding<ItemExcitingMomentsListBinding>().apply {
                if (modelPosition == 0) {
                    tvTimeFirst.text = "活动时间：" + bean.createdate?.substring(0, 10)
                    rlBottom.background =
                        context.getDrawable(R.drawable.shape_rect_001052_10dp_bottom_70)
                    tvTimeFirst.visible()
                    tvTitle.setTextColor(Color.parseColor("#FFFFFF"))
                    tvTime.gone()
                } else {
                    tvTime.text = "活动时间：" + bean.createdate?.substring(0, 10)
                    rlBottom.background =
                        context.getDrawable(R.drawable.shape_rect_f3f3f3_10dp_bottom)
                    tvTimeFirst.gone()
                    tvTime.visible()
                    tvTitle.setTextColor(Color.parseColor("#333333"))
                }
                img.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                if (bean.seecount.toString().isEmpty()) {
                    bean.seecount = "0"
                }
                tvLookCount.text = bean.seecount.toString() + "位同学看过"

            }
        }
        R.id.rl.onClick {
            context.start(ExcitingMomentDetailAct::class.java) {
                putExtra("jingcaiid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
fun RecyclerView.courseClass(): BindingAdapter {
    return grid(4).setup {
        addType<DataListBean>(R.layout.item_course_class)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseClassBinding>().apply {
                tvTitle.text = bean.title
                tvContent.text = bean.seecount + "位同学观看"
                img.loadRound(bean.coverimage!!, 7, true)
            }
        }
        R.id.rl.onClick {
            context.start(CourseDetailAct::class.java) {
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.bindStudent(type: String): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_bind_student)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemBindStudentBinding>().apply {
                btnCancel.setRoundRectBg(
                    Color.parseColor("#E2E7FF"), context.dp2px(12.5f).toInt()
                )
                headImg.loadCircle(bean.image!!)
                tvName.text = bean.name
                tvStudentNo.text = "学号：" + bean.xuehao
                tvInteractionCode.text = "互动码：" + bean.hudong
            }
        }
        R.id.rl.onClick {
            when (type) {
                "1" -> {
                    context.child_id = (getModel(modelPosition) as DataListBean).id.toString()
                    context.child_name = (getModel(modelPosition) as DataListBean).name.toString()
                    context.finish()
                }

                "2" -> {
                    context.child_id = (getModel(modelPosition) as DataListBean).id.toString()
                    context.child_name = (getModel(modelPosition) as DataListBean).name.toString()
                    context.start(MyClassAct::class.java)
                    context.finish()
                }
            }

        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.messageList(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_message)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemMessageBinding>().apply {
                rl.background = context.getDrawable(R.drawable.shape_rect_white_10dp)
                when (bean.type) {

                    "6" -> {
                        if (bean.pinglunrenshu?.isNotEmpty() == true && bean.pinglunrenshu != "0") {
                            tvName.text = bean.name + "...等" + bean.pinglunrenshu + "人评论了你"
                        } else {
                            tvName.text = bean.name + "评论了你"
                        }

                        if (bean.image?.contains(",") == true) {
                            rlImageMore.visible()
                            headImg.gone()
                            headImg1.loadCircle(bean.image!!.split(",")[0])
                            headImg2.loadCircle(bean.image!!.split(",")[1])
                        } else {
                            headImg.visible()
                            rlImageMore.gone()
                        }

                        imgTeacherFlag.gone()
                    }

                    "8" -> {
                        tvName.text = bean.title
                        imgTeacherFlag.gone()
                        tvContent.text = "签到异常,请及时处理"
                        when (bean.colorstate) {
                            "1" -> {
                                rl.background =
                                    context.getDrawable(R.drawable.bg_border_ffeded_11dp)
                            }

                            "2" -> {
                                rl.background =
                                    context.getDrawable(R.drawable.bg_border_ecfffe_11dp)
                            }
                        }
                    }


                    else -> {
                        tvName.text = bean.teachername + "老师"

                        imgTeacherFlag.visible()
                    }
                }
                headImg.loadCircle(bean.image!!)
                tvContent.text = bean.title
//                tvTime.text = bean.createdate?.subSequence(5, 10)
                tvTime.text =
                    DateUtils.convertTimeToFormatSmartCourse(DateUtils.stringToTimeStamp(bean.createdate));


                rl.setRoundRectBg(
                    Color.parseColor("#FFFFFF"), context.dp2px(10f).toInt()
                )
            }
        }

        R.id.rl.onClick {
            when (getModel<DataListBean>(modelPosition).type) {
//                0 -> {
//                    context.start(AbNormalTotalAct::class.java)
//                }
//
//                1 -> {
//                    context.start(SystemMessageAct::class.java)
//                }
//

//
////                3 -> {
////                    context.start(TaskMessageAct::class.java)
////                }
//
//                4 -> {
//                    context.start(CommentDetailAct::class.java)
//                }

                "2" -> {
                    context.start(InviteMessageAct::class.java) {
                        putExtra("classid", (models?.get(modelPosition) as DataListBean).classid)
                        putExtra(
                            "inviteName", (models?.get(modelPosition) as DataListBean).teachername
                        )
                        putExtra(
                            "inviteDate", (models?.get(modelPosition) as DataListBean).createdate
                        )
                    }
                }

                "6" -> {
                    context.start(CommentDetailAct::class.java) {
                        putExtra("type", "1")
                        putExtra("id", getModel<DataListBean>(modelPosition).renwuid)
                        putExtra("xiaojieid", getModel<DataListBean>(modelPosition).xiaojieid)
                    }
                }

                "7" -> {
                    context.start(TeacherSendMessageAct::class.java) {
                        putExtra("type", "1")
                        putExtra("classid", (models?.get(modelPosition) as DataListBean).classid)
                    }
                }

                "8" -> {
                    context.start(AbNormalTotalAct::class.java) {
                        putExtra("classid", (models?.get(modelPosition) as DataListBean).classid)
                    }
                }

            }
        }


    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.groupMember(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_message)
        singleMode = false
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemMessageBinding>().apply {
                headImg.loadCircle(bean.image!!)
                tvName.text = bean.name
                tvContent.text = bean.hudongcode
                rl.setRoundRectBg(
                    Color.parseColor("#FFFFFF"), context.dp2px(10f).toInt()
                )
                tvDelete.visible()
                tvTime.gone()
                if (checkedPosition.contains(modelPosition)) {
                    tvAdd.gone()
                } else {
                    tvAdd.visible()
                }
            }
        }

        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }


    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.taskScore(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_task_score)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemTaskScoreBinding>().apply {
                rl.setRoundRectBg(
                    Color.parseColor("#FFFFFF"), context.dp2px(10f).toInt()
                )
                img.loadRound(bean.imageurl!!, 10, true)
                tvName.text = bean.name
                tvScore.text = bean.source!!.toDouble().toInt().toString() + "分"
            }
        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.imgList(type: Int): BindingAdapter {
    return grid(3).setup {
        addType<DataListBean>(R.layout.item_img)
        addType<String>(R.layout.item_img)
        singleMode = true
        onBind {
            when (type) {
                1 -> {
                    val bean = getModel<DataListBean>()
                    getBinding<ItemImgBinding>().apply {
                        img.loadRound(bean.bimageurl!!, 10, true)
                        if (bean.imageurl?.isNotEmpty() == true) {
                            imgHuizhang.loadRound(bean.imageurl, 10, true)
                            imgHuizhang.visible()
                        } else
                            imgHuizhang.gone()
//                        if(bean.imageurl?.isNotEmpty()==true && bean.bimageurl?.isNotEmpty() == true){
//                            img.loadRound(bean.imageurl!!, 10, true)
//                        }else if( bean.bimageurl?.isNotEmpty() == true){
//                            img.loadRound(bean.bimageurl!!, 10, true)
//                        }
                    }
                }

                2 -> {
                    val bean = getModel<String>()
                    getBinding<ItemImgBinding>().apply {
                        img.loadRound(bean, 10, true)
                    }
                }
            }

        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.classTeacher(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_class_teacher)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemClassTeacherBinding>().apply {
                ivTeacherFlag.visible()
                tvName.text = bean.name
                tvContent.text = bean.createdate + " 加入"
                headImg.loadCircle(bean.image!!)

                when (bean.ifpingjia) {
                    "1" -> tvEvaluate.text = "去评价"
                    else -> tvEvaluate.text = "已评价"
                }
                when (context.user_role) {
                    3 -> {
                        tvEvaluate.gone()
                    }

                    else -> {
                        tvEvaluate.visible()
                    }
                }
            }
        }
        R.id.tvEvaluate.onClick {
            context.start(QuestionnaireDetailAct::class.java) {
                if ((getModel(modelPosition) as DataListBean).ifpingjia == "1") putExtra("type", 2)
                else putExtra("type", 3)
                putExtra("teacherid", (getModel(modelPosition) as DataListBean).id)
            }
        }


    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.evaluateQuestionWeiduList(): BindingAdapter {
    return linear().setup {
        addType<EvaluationQuestionsDto>(R.layout.item_evaluate_question_weidu)
        singleMode = true
        onBind {
            val bean = getModel<EvaluationQuestionsDto>()
            getBinding<ItemEvaluateQuestionWeiduBinding>().apply {
                tvWeiDu.text = bean.weiduname
                tvNum.text = bean.nums
            }
        }
        R.id.tvEvaluate.onClick {
            context.start(QuestionnaireDetailAct::class.java) {
                putExtra("type", 2)
            }
        }


    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.excitingMomentManager(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_exciting_moments_manager)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemExcitingMomentsManagerBinding>().apply {
                tvName.text = bean.title
                tvTime.text = bean.createdate
                img.loadRound(bean.url!!, 10, true)
            }
        }

        R.id.btnChangeName.onClick {
            context.commonEditTextDialog(
                1,
                (models?.get(modelPosition) as DataListBean).id!!,
                "修改名称",
                hint = "请输入名称",
                cancel = "取消",
                sure = "确认"
            )
        }


    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseReview(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_review)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseReviewBinding>().apply {

                if (bean.iffenzu == "1" && bean.cid!!.isNotEmpty()) {//组队
                    rlSingle.gone()
                    rlGroup.visible()
                } else {
                    rlSingle.visible()
                    rlGroup.gone()
                }
                tvTitle.text = bean.title
                tvName.text = bean.name
                tvContent.text = bean.createdate
                if (bean.image != null && bean.image!!.isNotEmpty()) headImg.loadCircle(bean.image!!)
                when (bean.state) {
                    "1" -> tvState.text = "待批阅"
                    "2" -> tvState.text = "批阅中"
                    "3" -> {
                        tvState.text = bean.source + "分"
                        tvState.setTextColor(Color.parseColor("#FF7073"))
                    }
                }

            }
        }

        R.id.rl.onClick {
            context.start(CommentDetailAct::class.java) {
                putExtra("id", (models?.get(modelPosition) as DataListBean).id)
                putExtra("xiaojieid", (models?.get(modelPosition) as DataListBean).xiaojieid)
                putExtra("type", "2")
                when ((models?.get(modelPosition) as DataListBean).state) {
                    "3" -> putExtra("fromAct", "4")
                }
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.scoreList(): BindingAdapter {
    return linear().setup {
        addType<EvaluationQuestionsDto>(R.layout.item_score_set)
        singleMode = true
        onBind {
            val bean = getModel<EvaluationQuestionsDto>()
            getBinding<ItemScoreSetBinding>().apply {
                tvTitle.text = bean.weiduname
                seekbar.max = bean.nums?.toInt()!!
                seekbar.setOnSeekBarChangeListener(object : OnSeekBarChangeListener {
                    override fun onProgressChanged(
                        seekBar: SeekBar?,
                        progress: Int,
                        fromUser: Boolean
                    ) {
                        val scoreDto = ScoreDto(bean.name, progress.toString())
                        sendEvent(scoreDto, "tag_set_score_data")
                    }

                    override fun onStartTrackingTouch(seekBar: SeekBar?) {

                    }

                    override fun onStopTrackingTouch(seekBar: SeekBar?) {

                    }

                })

            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.groupDetail(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_review)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseReviewBinding>().apply {
                if (bean.ifzudui == "1") {//组队
                    rlSingle.gone()
                    rlGroup.visible()
                } else {
                    rlSingle.visible()
                    rlGroup.gone()
                }

                tvTitle.text = bean.groupname
                tvGroupName.text = "组别：" + bean.grouptitle
                tvGroupNum.text = "组员：" + bean.groupstudent
                tvName.text = bean.grouptitle
                tvContent.text = bean.createdate
                tvGroupTime.text = bean.createdate
                headImg.gone()
                if (bean.image != null && bean.image!!.isNotEmpty()) headImg.loadCircle(bean.image!!)
                when (bean.state) {
                    "1" -> tvState.text = "待批阅"
                    "2" -> tvState.text = "批阅中"
                    "3" -> {
                        tvState.text = bean.defen + "分"
                        tvState.setTextColor(Color.parseColor("#FF7073"))
                    }
                }

            }
        }

        R.id.rl.onClick {
            context.start(CommentDetailAct::class.java) {
                putExtra("id", (models?.get(modelPosition) as DataListBean).id)
                putExtra("xiaojieid", (models?.get(modelPosition) as DataListBean).smallid)
                putExtra("type", "2")
                when ((models?.get(modelPosition) as DataListBean).state) {
                    "3" -> putExtra("fromAct", "4")
                }
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseReviewClassStudent(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_review_class_student)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseReviewClassStudentBinding>().apply {

                if (bean.ifgroup == "1") {//组队
                    rlSingle.gone()
                    rlGroup.visible()
                } else {
                    rlSingle.visible()
                    rlGroup.gone()
                }
                tvTitle.text = bean.title
                tvName.text = "姓名：" + bean.customername
                tvGroupName.text = "组名:" + bean.customername
                tvGroupNum.text = "组员:" + bean.zuyuan
                tvContent.text = "提交时间：" + bean.createtime
                tvGroupTime.text = "提交时间：" + bean.createtime
                if (bean.customerimage != null && bean.customerimage!!.isNotEmpty()) headImg.loadCircle(
                    bean.customerimage!!
                )
                tvState.setTextColor(Color.parseColor("#009B93"))
                when (bean.state) {
                    "1" -> tvState.text = "待批阅"
                    "2" -> tvState.text = "批阅中"
                    "3" -> {
                        tvState.text = bean.source + "分"
                        tvState.setTextColor(Color.parseColor("#FF7073"))
                    }
                }

            }
        }

        R.id.rl.onClick {
            context.start(CommentDetailAct::class.java) {
                putExtra("id", (models?.get(modelPosition) as DataListBean).id)
                putExtra("xiaojieid", (models?.get(modelPosition) as DataListBean).xiaojieid)
                putExtra("type", "2")
                when ((models?.get(modelPosition) as DataListBean).state) {
                    "3" -> putExtra("fromAct", "4")
                }
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseRecommend(): BindingAdapter {
    return grid(2).setup {
        addType<DataListBean>(R.layout.item_course_recommend)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseRecommendBinding>().apply {

                rl.setRoundRectBg(
                    Color.parseColor("#ADADAD"), context.dp2px(10f).toInt()
                )
                headImg.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                tvLookNum.text = bean.seecount + "位同学浏览"
                tvTime.text = bean.createdate?.substring(0, 10)


            }
        }

        R.id.rl.onClick {
            context.start(CourseDetailAct::class.java) {
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseMyCreate(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_my_create)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseMyCreateBinding>().apply {
                tvTitle.text = bean.title
                tvTime.text = "上课时间：" + bean.begintime?.substring(0, 16)
                tvClass.text = bean.suoshuclass
                img.loadRound(bean.coverimage!!, 10, true)
                tvContent.text = bean.brief + "小节·" + bean.joincount + "人参与"
                tvSubject.text = bean.lable

            }
        }

        R.id.rl.onClick {
            context.start(SmartCourseDetailAct::class.java) {
                putExtra("type", "1")
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }

    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseMyAttend(type: Int): BindingAdapter {//1    2班级详情
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_my_attend)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseMyAttendBinding>().apply {
                tvTitle.text = bean.title
                tvTime.text = "上课时间：" + bean.begintime?.substring(0, 16)
                tvClass.text = bean.suoshuclass
                img.loadRound(bean.coverimage!!, 10, true)
                tvContent.text = bean.brief + "小节·" + bean.joincount + "人参与"
                tvSubject.text = bean.lable
                tvTeacherName.text = bean.teachername
                imgTeacher.loadCircle(bean.teacherimage!!)
                when (type) {
                    1 -> {
                        if (bean.ydbriefcount?.isEmpty() == true) {
                            progressbar.progress = 0
                            tvProgress.text = "0%"
                        } else {
                            if (bean.brief!!.toInt() == 0) {
                                progressbar.progress = 0
                                tvProgress.text = "0%"
                            } else {
                                progressbar.progress =
                                    ((bean.ydbriefcount!!.toDouble() / bean.brief!!.toDouble()).round(
                                        2,
                                        BigDecimal.ROUND_HALF_UP
                                    ) * 100).toInt()

                                tvProgress.text =
                                    progressbar.progress.toString() + "%"
                            }
                        }
                    }

                    2 -> {
                        if (bean.ydbriefcount?.isEmpty() == true) {
                            progressbar.progress = 0
                            tvProgress.text = "0%"
                        } else {
                            if (bean.brief!!.toInt() == 0) {
                                progressbar.progress = 0
                                tvProgress.text = "0%"
                            } else {
                                progressbar.progress =
                                    ((bean.ydbriefcount!!.toDouble() / bean.brief!!.toDouble()).round(
                                        2,
                                        BigDecimal.ROUND_HALF_UP
                                    ) * 100).toInt()

                                tvProgress.text =
                                    progressbar.progress.toString() + "%"
                            }
                        }
                    }
                }

            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.courseManager(taskType: String): BindingAdapter {
    return linear().setup {
        when (taskType) {
            "1" -> addType<DataListBean>(R.layout.item_course_type_1)
            "2" -> addType<DataListBean>(R.layout.item_course_type_2)
            "3" -> addType<DataListBean>(R.layout.item_course_type_3)
        }
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            when (taskType) {
                "1" -> {
                    getBinding<ItemCourseType1Binding>().apply {
                        tvTitle.text = bean.title
                        tvTime.text = "上课时间：" + bean.begintime
                        tvClass.text = bean.suoshuclass
                        img.loadRound(bean.coverimage!!, 10, true)
                        tvContent.text = bean.brief + "小节·" + bean.joincount + "人参与"
                        tvSubject.text = bean.lable
                    }
                }

                "2" -> {
                    getBinding<ItemCourseType2Binding>().apply {
                        img.loadRound(bean.coverimage!!, 10, true)
                        tvTitle.text = bean.title
                        tvTeacherName.text = bean.teachername
                        if (bean.briefcount?.isEmpty() == true) tvContent.text =
                            "0小节·" + bean.joincount + "人参与"
                        else tvContent.text = bean.briefcount + "小节·" + bean.joincount + "人参与"
                        tvTime.text = bean.begintime?.substring(0, 16)
                    }
                }

                "3" -> {
                    getBinding<ItemCourseType3Binding>().apply {
                        img.loadRound(bean.coverimage!!, 10, true)
                        tvTitle.text = bean.title
                        tvDifficulty.text = bean.nandu


                        when (bean.state) {
                            "1" -> {
                                tvTime.text = "未发布"
                                tvDay.gone()
                            }

                            else -> {
                                tvTime.text = bean.begintime
                                tvDay.visible()
                            }
                        }

                        when (bean.ifjieshu) {
                            "1" -> tvDay.text = "已结束"
                            else -> tvDay.text = "第" + bean.day + "天"
                        }

                        when (bean.nandu) {
                            "简单" -> ratingBar.setStar(1f)
                            "中等" -> ratingBar.setStar(3f)
                            "困难" -> ratingBar.setStar(5f)
                        }
                        ratingBar.isClickable = false
                        recycler.oneText(2).models = bean.biaoqianlist
                    }

                }
            }

        }
    }
}


@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
fun RecyclerView.classVenueTasks(type: Int): BindingAdapter {//type 1主题场馆  2班级详情
    return linear().setup {
        addType<DataListBean>(R.layout.item_class_venue_task)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemClassVenueTaskBinding>().apply {
                img.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                tvTeacherName.text = bean.teachername
                if (bean.briefcount?.isEmpty() == true) tvContent.text =
                    "0小节·" + bean.joincount + "人参与"
                else tvContent.text = bean.briefcount + "小节·" + bean.joincount + "人参与"
                tvTime.text = bean.begintime?.substring(0, 16)
                when (type) {
                    1 -> {
                        if (bean.briefcount?.isNotEmpty() == true && bean.briefcount != "0") {
                            progressbar.progress =
                                ((bean.ydbriefcount?.toDouble()!! / bean.briefcount?.toDouble()!!).round(
                                    2,
                                    BigDecimal.ROUND_HALF_UP
                                ) * 100).toInt()

                            tvProgress.text =
                                progressbar.progress.toString() + "%"
                        } else {
                            progressbar.progress = 0
                            tvProgress.text = "0%"
                        }
                    }

                    2 -> {
                        if (bean.brief?.isNotEmpty() == true && bean.brief != "0") {
                            progressbar.progress =
                                ((bean.ydbriefcount?.toDouble()!! / bean.brief?.toDouble()!!).round(
                                    2,
                                    BigDecimal.ROUND_HALF_UP
                                ) * 100).toInt()

                            tvProgress.text =
                                progressbar.progress.toString() + "%"
                        } else {
                            progressbar.progress = 0
                            tvProgress.text = "0%"
                        }
                    }
                }

                when (bean.ifwancheng) {
                    "1" -> {
                        ivFinish.visible()
                        bean.icon?.let { it1 -> ivFinish.loadRound(it1, 10, true) }
                    }

                    else -> {
                        ivFinish.gone()
                    }
                }
            }
        }
        R.id.rl.onClick {
            context.start(SmartCourseDetailAct::class.java) {
                putExtra("type", "2")
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.classStudent(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_class_student)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemClassStudentBinding>().apply {
                tvName.text = bean.name
                tvTime.text = bean.createdate + "加入"
                tvStudentNo.text = "互动码：" + bean.hudongcode
                tvStudentId.text = "学号：" + bean.xuecode
                headImg.loadCircle(bean.image!!)
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.classNotice(classid: String): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_class_notice)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemClassNoticeBinding>().apply {
                headImg.loadCircle(bean.createimage!!)
                tvName.text = bean.createname + "老师"
                tvContent.text = bean.title
                tvTime.text = bean.createdate
            }
        }

        R.id.ll.onClick {
            context.start(TeacherSendMessageAct::class.java) {
                putExtra("type", "1")
                putExtra("classid", classid)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
fun RecyclerView.courseChapter(
    taskType: String,
    courseState: String? = null,
    baomingState: String? = null,
    ifwon: String? = null
): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_course_chapter)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCourseChapterBinding>().apply {
                when (taskType) {
                    "3" -> {
//                        tvChapterNo.text =
//                            "第" + NumberFormatUtil.numberToChinese(modelPosition + 1)
//                                .toString() + "天"
                        tvChapterNo.text = bean.jindu
                        recycler.chapterExercises(
                            modelPosition,
                            models?.get(modelPosition) as DataListBean,
                            taskType,
                            courseState,
                            baomingState,
                            ifwon
                        ).models = bean.small
                    }

                    else -> {
                        tvChapterNo.text =
                            "第" + NumberFormatUtil.numberToChinese(modelPosition + 1)
                                .toString() + "章"
                        recycler.chapterExercises(
                            modelPosition, models?.get(modelPosition) as DataListBean, taskType
                        ).models = bean.small
                    }
                }
                tvChapterName.text = bean.title
                tvChapterNo.setRoundRectBg(
                    Color.parseColor("#F3F3F3"), context.dp2px(15f).toInt()
                )
                tvExpand.visible()
                when (context.user_role) {
                    3 -> {
                        if (taskType == "3") {
                            if (courseState == "1" && ifwon == "1") tvSet.visible()
                            else tvSet.gone()
                        } else {
                            tvSet.visible()
                        }
                    }
                }


                if (bean.expandFlag == "1") {
                    tvExpand.text = "收起"
                    recycler.visible()
                } else {
                    tvExpand.text = "展开"
                    recycler.gone()
                }

            }
        }

        R.id.tvSet.onClick {
            context.setChapterDialog(
                getBinding<ItemCourseChapterBinding>().tvSet,
                1,
                taskType,
                modelPosition,
                models?.get(modelPosition) as DataListBean
            )
        }

        R.id.tvExpand.onClick {
            if ((models?.get(modelPosition) as DataListBean).expandFlag == "1") {
                getBinding<ItemCourseChapterBinding>().recycler.gone()
                getBinding<ItemCourseChapterBinding>().tvExpand.text = "展开"
                (models?.get(modelPosition) as DataListBean).expandFlag = "2"
            } else {
                getBinding<ItemCourseChapterBinding>().recycler.visible()
                getBinding<ItemCourseChapterBinding>().tvExpand.text = "收起"
                (models?.get(modelPosition) as DataListBean).expandFlag = "1"
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.chapterExercises(
    parentPosition: Int,
    dataListBean: DataListBean,
    taskType: String,
    courseState: String? = null,
    baomingState: String? = null,
    ifwon: String? = null
): BindingAdapter {
    return linear().setup {
        addType<Small>(R.layout.item_course_chapter_exercises)
        singleMode = true
        onBind {
            val bean = getModel<Small>()
            getBinding<ItemCourseChapterExercisesBinding>().apply {

                tvExercisesName.text = bean.title
                when (context.user_role) {
                    1 -> {
                        tvAnswered.visible()
                        when (bean.type) {
                            "1" -> {
                                if (bean.ifzt == "1") {
                                    tvAnswered.text = "学生未答"
                                    tvAnswered.isSelected = false
                                } else {
                                    tvAnswered.text = "学生已答"
                                    tvAnswered.isSelected = true

                                }
                            }

                            "2" -> {
                                if (bean.ifzt == "1") {
                                    tvAnswered.text = "学生未答"
                                    tvAnswered.isSelected = false
                                } else {
                                    tvAnswered.text = "学生已答"
                                    tvAnswered.isSelected = true
                                }
                            }

                            "3" -> {
                                if (bean.ifqiandao == "1") {
                                    tvAnswered.text = "已签到"
                                    tvAnswered.isSelected = false
                                    rl.isClickable = false
                                } else {
                                    tvAnswered.text = "未签到"
                                    tvAnswered.isSelected = false
                                    rl.isClickable = false
                                }
                            }
                        }
                    }

                    2 -> {
                        tvAnswered.visible()
                        when (taskType) {
                            "3" -> {
                                when (baomingState) {
                                    "2" -> {
                                        tvAnswered.visible()
                                        rl.isClickable = true
                                        when (bean.type) {
                                            "1" -> {
                                                if (bean.ifzt == "1") {
                                                    tvAnswered.text = "去练习"
                                                    tvAnswered.isSelected = true
                                                } else {
                                                    tvAnswered.text = "查看"
                                                    tvAnswered.isSelected = false
                                                }
                                            }

                                            "2" -> {
                                                if (bean.ifzt == "1") {
                                                    tvAnswered.text = "去练习"
                                                    tvAnswered.isSelected = true
                                                } else {
                                                    tvAnswered.text = "查看"
                                                    tvAnswered.isSelected = false
                                                }
                                            }

                                            "3" -> {
                                                if (bean.ifqiandao == "1") {
                                                    tvAnswered.text = "已签到"
                                                    tvAnswered.isSelected = false
                                                    rl.isClickable = false
                                                } else {
                                                    tvAnswered.text = "去签到"
                                                    tvAnswered.isSelected = true
                                                    rl.isClickable = true
                                                }
                                            }
                                        }
                                    }

                                    else -> {
                                        tvAnswered.gone()
                                        rl.isClickable = false
                                    }
                                }
                            }

                            else -> {
                                when (bean.type) {
                                    "1" -> {
                                        if (bean.ifzt == "1") {
                                            tvAnswered.text = "去练习"
                                            tvAnswered.isSelected = true
                                        } else {
                                            tvAnswered.text = "查看"
                                            tvAnswered.isSelected = false
                                        }
                                    }

                                    "2" -> {
                                        if (bean.ifzt == "1") {
                                            tvAnswered.text = "去练习"
                                            tvAnswered.isSelected = true
                                        } else {
                                            tvAnswered.text = "查看"
                                            tvAnswered.isSelected = false
                                        }
                                    }

                                    "3" -> {
                                        if (bean.ifqiandao == "1") {
                                            tvAnswered.text = "已签到"
                                            tvAnswered.isSelected = false
                                            rl.isClickable = false
                                        } else {
                                            tvAnswered.text = "去签到"
                                            tvAnswered.isSelected = true
                                            rl.isClickable = true
                                        }
                                    }
                                }
                            }
                        }

                    }

                    3 -> {
                        when (taskType) {
                            "3" -> {
                                when (courseState) {
                                    "2" -> {
                                        tvManager.gone()
                                        tvAnswered.visible()
                                        tvAnswered.text = "查看"

                                    }

                                    else -> {
                                        tvManager.visible()
                                        tvAnswered.gone()
                                    }
                                }
                            }

                            else -> {
                                tvManager.visible()
                                tvAnswered.gone()
                            }
                        }
                    }
                }
            }
        }
        R.id.rl.onClick {
            context.chapterPosition = modelPosition + 1
            when (context.user_role) {
                1 -> {
                    context.start(PracticeDetailAct::class.java) {
                        putExtra("type", (models?.get(modelPosition) as Small).type)
                        putExtra("samllid", (models?.get(modelPosition) as Small).id)
                    }
                }

                2 -> {
                    context.start(PracticeDetailAct::class.java) {
                        putExtra("type", (models?.get(modelPosition) as Small).type)
                        putExtra("samllid", (models?.get(modelPosition) as Small).id)
                        putExtra("ifzt", (models?.get(modelPosition) as Small).ifzt)
                    }
                }

                3 -> {
//                    if (ifwon != "1") {
//                        context.start(PracticeDetailAct::class.java) {
//                            putExtra("type", (models?.get(modelPosition) as Small).type)
//                            putExtra("samllid", (models?.get(modelPosition) as Small).id)
//                            putExtra("ifzt", (models?.get(modelPosition) as Small).ifzt)
//                        }
//                    }
                }
            }
        }

        R.id.tvManager.onClick {
            context.setChapterDialog(
                getBinding<ItemCourseChapterExercisesBinding>().tvManager,
                2,
                taskType,
                parentPosition,
                dataListBean,
                small = models?.get(modelPosition) as Small
            )
        }

        R.id.tvLook.onClick {
            context.start(AddSmallChapterAct::class.java) {
                putExtra("dataListBean", models?.get(modelPosition) as DataListBean)
            }
        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.yanXueCenter(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_yanxue_center)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemYanxueCenterBinding>().apply {
                when (context.user_role) {
                    1, 2 -> {
                        tvSet.gone()
                    }

                    3 -> {
                        when (bean.ifwon) {
                            "1" -> tvSet.visible()
                            else -> tvSet.gone()
                        }

                    }
                }
                img.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                tvDifficulty.text = bean.nandu


                when (bean.state) {
                    "1" -> {
                        tvTime.text = "未发布"
                        tvDay.gone()
                    }

                    else -> {
                        tvTime.text = bean.begintime
                        tvDay.visible()
                    }
                }

                when (bean.ifjieshu) {
                    "1" -> tvDay.text = "已结束"
                    else -> {
                        if (bean.day.isNullOrEmpty()) {
                            tvDay.text = "未开始"
                        } else {
                            tvDay.text = bean.day
                        }
                    }
                }

                when (bean.nandu) {
                    "简单" -> ratingBar.setStar(1f)
                    "中等" -> ratingBar.setStar(3f)
                    "困难" -> ratingBar.setStar(5f)
                }
                ratingBar.isClickable = false
//                val listBean = ArrayList<DataListBean>()
//                for (i in 0 until bean.biaoqianlist?.size!!) {
//                    val dataListBean = DataListBean()
//                    dataListBean.name = bean.biaoqianlist!![i]
//                    listBean.add(dataListBean)
//                }
                recycler.oneText(2).models = bean.biaoqianlist
            }
        }

        R.id.tvSet.onClick {
            context.sourceSetDialog(
                "3", models?.get(modelPosition) as DataListBean
            )
        }

        R.id.rl.onClick {
            context.start(YanXueDetailAct::class.java) {
                putExtra("type", "3")
                putExtra("sendType", (models?.get(modelPosition) as DataListBean).sendType)
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.setGroup(courseid: String): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_set_group)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemSetGroupBinding>().apply {
                tvGroupName.text = bean.groupname
                tvGroupMemberCount.text = "学员" + bean.studentcount + "人"
                val listBean = bean.teachers
                rcvTeacher.teacherLeader(
                    1, (models?.get(modelPosition) as DataListBean).groupid!!
                ).models = listBean

            }
        }

        R.id.tvAddTeacher.onClick {
            context.selectGroupMemberDialog(
                "选择老师", 2, (models?.get(modelPosition) as DataListBean).groupid!!, courseid
            )
        }
        R.id.tvAddStudent.onClick {
            context.selectGroupMemberDialog(
                "选择学员", 1, (models?.get(modelPosition) as DataListBean).groupid!!, courseid
            )

        }
        R.id.tvLookStudent.onClick {
            context.selectGroupMemberDialog(
                "查看成员", 3, (models?.get(modelPosition) as DataListBean).groupid!!, courseid
            )

        }


    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.teacherLeader(type: Int, groupid: String? = null): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_teacher_leader)
        addType<TeacherBean>(R.layout.item_teacher_leader)
        singleMode = true
        onBind {
            if (type == 1) {
                val bean = getModel<TeacherBean>()
                getBinding<ItemTeacherLeaderBinding>().apply {
                    tvScore.gone()
                    imgDelete.visible()
                    if (bean.image!!.isNotEmpty()) headImg.loadCircle(bean.image!!)
                    tvName.text = bean.name
                    tvInteractionCode.text = "互动码:" + bean.hudong
                }
            } else {
                val bean = getModel<DataListBean>()
                getBinding<ItemTeacherLeaderBinding>().apply {
                    tvScore.visible()
                    when (bean.state) {
                        "1" -> tvScore.text = "待批阅"
                        "2" -> tvScore.text = "批阅中"
                        "3" -> tvScore.text = bean.source + "分"
                    }

                    imgDelete.gone()
                    if (bean.image!!.isNotEmpty()) headImg.loadCircle(bean.image!!)
                    tvName.text = bean.name
                    tvInteractionCode.text = "提交时间:" + bean.createdate
                }
            }

        }
        R.id.imgDelete.onClick {
            scopeNetLife {
                if (type == 1) {
                    delteacherorstudent(
                        groupid!!, (models?.get(modelPosition) as TeacherBean).id!!, "2"
                    )
                    context.saveSuccessDialog("删除成功")
                    sendEvent("cs", "refreshGroupList")
                } else {
                    delteacherorstudent(
                        groupid!!, (models?.get(modelPosition) as DataListBean).id!!, "1"
                    )
                    context.saveSuccessDialog("删除成功")
                    sendEvent("cs", "refreshGroupList")
                }

//                val rxManager = RxManager()
//                rxManager.post("refreshDialogGroupList", "cs")
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.selectGroupMember(type: Int, groupid: String? = null): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_select_group_member)
        singleMode = false
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemSelectGroupMemberBinding>().apply {
                when (type) {
                    1 -> {
                        tvDelete.gone()
                        imgSelect.visible()
                    }

                    2 -> {
                        tvDelete.gone()
                        imgSelect.visible()
                    }

                    3 -> {
                        tvDelete.visible()
                        imgSelect.gone()
                    }

                    4 -> {
                        tvDelete.gone()
                        imgSelect.gone()
                    }
                }

                headImg.loadCircle(bean.image!!)
                tvName.text = bean.name
                tvInteractionCode.text = "互动码：" + bean.hudongcode
                imgSelect.isSelected = checkedPosition.contains(modelPosition)
            }
        }
        R.id.tvDelete.onClick {
            scopeNetLife {
                delteacherorstudent(
                    groupid!!, (models?.get(modelPosition) as DataListBean).id!!, "1"
                )
                context.saveSuccessDialog("删除成功")
                sendEvent("cs", "refreshGroupList")
//                val rxManager = RxManager()
//                rxManager.post("refreshDialogGroupList", "cs")
            }
        }

        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }

        R.id.rl.onClick {
            setChecked(modelPosition, !checkedPosition.contains(modelPosition))
        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.messageUnreadList(): BindingAdapter {
    return linear().setup {
        addType<StudentBean>(R.layout.item_select_group_member)
        singleMode = true
        onBind {
            val bean = getModel<StudentBean>()
            getBinding<ItemSelectGroupMemberBinding>().apply {
                tvDelete.gone()
                imgSelect.gone()

                headImg.loadCircle(bean.image!!)
                tvName.text = bean.name
                tvInteractionCode.text = "互动码：" + bean.hudongcode
                imgSelect.isSelected = checkedPosition.contains(modelPosition)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.oneText(type: Int? = null): BindingAdapter {
    return linear(HORIZONTAL).setup {
        addType<DataListBean>(R.layout.item_text)
        addType<BiaoQianBean>(R.layout.item_text)
        addType<String>(R.layout.item_text)
        singleMode = true
        onBind {
            when (type) {
                3 -> {
                    val bean = getModel<DataListBean>()
                    getBinding<ItemTextBinding>().apply {
                        tv.text = bean.name
                        tv.setRoundRectBg(
                            Color.parseColor("#F3F3F3"), context.dp2px(3f).toInt()
                        )
                    }
                }

                1 -> {
                    val bean = getModel<BiaoQianBean>()
                    getBinding<ItemTextBinding>().apply {
                        tv.text = bean.name
                        tv.setRoundRectBg(
                            Color.parseColor("#F3F3F3"), context.dp2px(3f).toInt()
                        )
                    }
                }

                2 -> {
                    val bean = getModel<String>()
                    getBinding<ItemTextBinding>().apply {
                        tv.text = bean
                        tv.setRoundRectBg(
                            Color.parseColor("#F3F3F3"), context.dp2px(3f).toInt()
                        )
                    }
                }
            }

        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.recyclerDialog(type: Int): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_recycler_dialog)
        singleMode = false
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemRecyclerDialogBinding>().apply {
                when (type) {
                    1 -> tv.text = bean.title
                    2 -> tv.text = bean.name
                    else -> tv.text = bean.name
                }
                if (checkedPosition.contains(modelPosition)) tv.setRoundRectBg(
                    Color.parseColor("#4B6AEF"), context.dp2px(10f).toInt()
                )
                else tv.setBackgroundResource(R.drawable.shape_rect_f3f3f3_10dp)
            }
        }
        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.recentAttend(): BindingAdapter {
    return grid(3).setup {
        addType<DataListBean>(R.layout.item_recent_attend)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemRecentAttendBinding>().apply {
                if (!bean.image.isNullOrEmpty()) img.loadRound(bean.image!!, 10, true)
                tvTitle.text = bean.name
            }
        }
        R.id.rl.onClick {
            when ((models?.get(modelPosition) as DataListBean).type) {
                "3" -> context.start(YanXueDetailAct::class.java) {
                    putExtra("type", "3")
                    putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
                }

                else -> context.start(SmartCourseDetailAct::class.java) {
                    putExtra("type", (models?.get(modelPosition) as DataListBean).type)
                    putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
                }
            }

        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.tab3Class(): BindingAdapter {
    return grid(5).setup {
        addType<DataListBean>(R.layout.item_grid_custom)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemGridCustomBinding>().apply {
                name.text = bean.name
                img.loadRound(bean.imageurl!!, 10, true)
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.studentRead(): BindingAdapter {
    return linear(HORIZONTAL, scrollEnabled = false).setup {
        addType<StudentBean>(R.layout.item_student_read)
        singleMode = true
        onBind {
            val bean = getModel<StudentBean>()
            getBinding<ItemStudentReadBinding>().apply {

                val imgLayoutParams = LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT
                )
                imgLayoutParams.width =
                    (((context as Activity).screenWidth() - context.dp2px(80f) + context.dp2px(24f)) / 9).toInt()
                imgLayoutParams.height =
                    (((context as Activity).screenWidth() - context.dp2px(80f) + context.dp2px(24f)) / 9).toInt()
                img.layoutParams = imgLayoutParams

                if (modelPosition != 0) {
                    val layoutParams = LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.WRAP_CONTENT,
                        LinearLayout.LayoutParams.WRAP_CONTENT
                    )
                    layoutParams.marginStart = context.dp2px(-3f).toInt()
                    rl.layoutParams = layoutParams
                }

                img.loadCircle(bean.image!!)
                tvName.text = bean.name


            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.tab3recycler(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_tab3_recycler)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemTab3RecyclerBinding>().apply {
                when (context.user_role) {
                    1, 2 -> {
                        rlStudent.visible()
                        tvSet.gone()
                        tvClass.gone()
                        tvTime.gone()
                        if (bean.state == "1") {
                            rl.gone()
                        } else {
                            rl.visible()
                        }
                    }

                    3 -> {
                        rlStudent.gone()
                        tvSet.visible()
                        tvClass.visible()
                        tvTime.visible()
                    }
                }
                img.loadRound(bean.coverimage!!, 10, true)
                tvTitle.text = bean.title
                tvTeacherName.text = bean.teachername
                tvContent.text = bean.briefcount + "小节·" + bean.joincount + "人参与"
                tvClass.text = bean.suoshuclass
                tvTime.text = "上课时间：" + bean.begintime
            }
        }

        R.id.rl.onClick {
            context.start(SmartCourseDetailAct::class.java) {
                putExtra("type", "2")
                putExtra("courseid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.questionnaire(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_questionnaire)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemQuestionnaireBinding>().apply {
                tvSendTime.text = bean.createdate
                tvTitle.text = bean.name
                if (bean.submittime.isNullOrEmpty()) {
                    tvSubmitTime.gone()
                } else {
                    tvSubmitTime.visible()
                    tvSubmitTime.text = bean.submittime
                }
                when (bean.state) {
                    "1" -> tvState.text = "未填写"
                    "2" -> tvState.text = "已填写"
                }
            }
        }
        R.id.rl.onClick {
            when (getModel<DataListBean>(modelPosition).state) {
                "1" -> context.start(QuestionnaireDetailAct::class.java) {
                    putExtra("type", 1)
                    putExtra("paperBean", models?.get(modelPosition) as DataListBean)
                }

                "2" -> context.start(QuestionnaireDetailAct::class.java) {
                    putExtra("type", 4)
                    putExtra("paperBean", models?.get(modelPosition) as DataListBean)
                }
            }

        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.questionnaireDetail(fromType: Int): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_questionnaire_detail)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemQuestionnaireDetailBinding>().apply {
                when (bean.type) {
                    "1" -> {
                        recycler.visible()
                        etAnswer.gone()
                        recycler.paperOptionListSingle(modelPosition, bean.myanswer).models =
                            bean.itemList
                    }

                    "2" -> {
                        recycler.visible()
                        etAnswer.gone()
                        recycler.paperOptionList(modelPosition, bean.myanswer).models =
                            bean.itemList
                    }

                    "3" -> {
                        when (fromType) {
                            1, 3 -> {
                                etAnswer.visible()
                                tvAnswer.gone()
                                etAnswer.setText("")
                            }

                            4, 2 -> {
                                etAnswer.gone()
                                tvAnswer.visible()
                                tvAnswer.text = bean.myanswer.toString()
                            }
                        }
                        recycler.gone()

                    }
                }

                tvTitle.text = bean.title


                etAnswer.doAfterTextChanged {
                    val topicListDto = TopicListDto(
                        (models?.get(modelPosition) as DataListBean).topicId.toString(),
                        it.toString(),
                        modelPosition
                    )
                    sendEvent(topicListDto, "zhuGuanTiAnswer")
                }
            }


        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.paperOptionListSingle(
    parentPosition: Int, myAnswer: String? = null
): BindingAdapter {
    return linear(HORIZONTAL).setup {
        addType<PaperItem>(R.layout.item_paper_option)
        singleMode = true
        onBind {
            val bean = getModel<PaperItem>()
            getBinding<ItemPaperOptionBinding>().apply {
                cbOption.text = bean.title
                cbOption.isChecked = checkedPosition.contains(modelPosition)
                cbOption.isClickable = false
                if (!myAnswer.isNullOrEmpty() && myAnswer == bean.itemId) {
                    cbOption.isChecked = true
                    ll.isClickable = false
                }
                ll.isClickable = myAnswer.isNullOrEmpty()

            }
        }

        onChecked { position, checked, _ ->
            notifyDataSetChanged()
        }

        R.id.ll.onClick {
            val paperItem = models?.get(modelPosition) as PaperItem
            paperItem.answer = (models?.get(modelPosition) as PaperItem).itemId
            paperItem.parentPosition = parentPosition
            sendEvent(paperItem, "itemAnswer")
            setChecked(
                modelPosition, true
            ) // 在点击事件中触发选择事件, 即点击列表条目就选中

        }

    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.paperOptionList(parentPosition: Int, myAnswer: String? = null): BindingAdapter {
    return linear(HORIZONTAL).setup {
        addType<PaperItem>(R.layout.item_paper_option)
        singleMode = false
        onBind {
            val bean = getModel<PaperItem>()
            getBinding<ItemPaperOptionBinding>().apply {
                cbOption.text = bean.title
                cbOption.isChecked = checkedPosition.contains(modelPosition)

                if (myAnswer?.contains(bean.itemId!!)!!) {
                    cbOption.isChecked = true
                }
                if (!myAnswer.isNullOrEmpty()) {
                    cbOption.isClickable = false
                    ll.isClickable = false
                }

                cbOption.setOnCheckedChangeListener { buttonView, isChecked ->
                    val paperItem = models?.get(modelPosition) as PaperItem
                    paperItem.answer = (models?.get(modelPosition) as PaperItem).itemId
                    paperItem.parentPosition = parentPosition
                    sendEvent(paperItem, "itemAnswer")
                }

            }

        }

        onChecked { position, checked, _ ->
            notifyDataSetChanged()
        }

        R.id.ll.onClick {

            setChecked(
                modelPosition, !checkedPosition.contains(modelPosition)
            ) // 在点击事件中触发选择事件, 即点击列表条目就选中

        }

    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.abnormalTotal(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_abnormal_total)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemAbnormalTotalBinding>().apply {
                tvSet.setRoundRectBg(Color.parseColor("#E2E7FF"), context.dp2px(12.5f).toInt())
                img.loadCircle(bean.image!!)
                tvTitle.text = bean.name
                tvContent.text = "互动码：" + bean.hudongcode
                tvClass.text = "所属班级：" + bean.classname

                when (bean.state) {
                    "1" -> {
                        tvSet.text = "处理"
                        tvSet.isClickable = true
                    }

                    "2" -> {
                        tvSet.text = "已处理"
                        tvSet.isClickable = false
                    }
                }
            }

            R.id.tvSet.onClick {
                scopeNetLife {
                    val baseBean = chuliweiqiandao(getModel<DataListBean>(modelPosition).id)
                    if (baseBean.result == "0") {
                        bindingAdapter?.notifyItemRemoved(modelPosition)
                        context.saveSuccessDialog("处理成功")
                    } else {
                        toast(baseBean.resultNote.toString())
                    }
                }
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.systemMessageList(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_system_message)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemSystemMessageBinding>().apply {
                tvTitle.text = bean.title
                tvTime.text = bean.createdate?.substring(0, 10)
                tvContent.text = bean.futitle
                if (bean.image.isNullOrEmpty()) {
                    img.gone()
                } else {
                    img.visible()
                    img.loadRound(bean.image!!, 10, true)
                }
            }
        }
        R.id.rl.onClick {
            context.start(WebHtmlActivity::class.java) {
                putExtra("title", getModel<DataListBean>(modelPosition).title)
                putExtra("url", getModel<DataListBean>(modelPosition).content)
                putExtra("type", 4)
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.messageBoardHistory(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_message_board_history)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemMessageBoardHistoryBinding>().apply {
                tvCrateTime.text = bean.createdate
                tvTitle.text = bean.content
                tvContent.text = bean.answer
                if (bean.image.isNullOrEmpty()) {
                    imgRecycler.gone()
                } else {
                    imgRecycler.visible()
                    val imgList = ArrayList<String>()
                    if (bean.image!!.contains("|")) {
                        imgList.addAll(bean.image!!.split("|"))
                    } else {
                        imgList.add(bean.image!!)
                    }
                    imgRecycler.imgList(2).models = imgList
                }

                if (bean.answertime.isNullOrEmpty()) {
                    rlReply.gone()
                } else {
                    rlReply.visible()
                    headImg.loadCircle(bean.answerimage!!)
                    tvCommentTime.text = bean.answertime
                }

            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.teacherSendMessage(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_message_teacher_send)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemMessageTeacherSendBinding>().apply {
                tvTitle.text = bean.title
                tvCrateTime.text = bean.createdate
                tvContent.text = bean.content
                tvReadCount.text = bean.yiducount + "人已读"

            }
        }

        R.id.rl.onClick {
            context.start(MessageDetailAct::class.java) {
                putExtra("calssnewsid", (getModel(modelPosition) as DataListBean).id)
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.taskMessage(taskType: String): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_message_task)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemMessageTaskBinding>().apply {
                tvTitle.text = bean.title
                tvTime.text = bean.createdate
                when (bean.type) {
                    "1" -> tvTaskState.text = "更新了新任务"
                    "2" -> tvTaskState.text = "邀请你加入新任务"
                }
                tvSubject.text = bean.lableid
            }
        }

        R.id.rl.onClick {

            when (taskType) {
                "3" -> {
                    context.start(SmartCourseDetailAct::class.java) {
                        putExtra("type", "1")
                        putExtra("courseid", (getModel(modelPosition) as DataListBean).courseid)
                    }
                }

                "4" -> {
                    context.start(SmartCourseDetailAct::class.java) {
                        putExtra("type", "2")
                        putExtra("courseid", (getModel(modelPosition) as DataListBean).courseid)
                    }
                }

                "5" -> {
                    context.start(YanXueDetailAct::class.java) {
                        putExtra("type", "3")
                        putExtra("courseid", (getModel(modelPosition) as DataListBean).courseid)
                    }
                }
            }
        }

    }
}

@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
fun RecyclerView.comment(type: Int): BindingAdapter {
    //type 1  推荐课程、精彩  2智慧课程等
    return linear().setup {
        addType<DataListBean>(R.layout.item_comment)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemCommentBinding>().apply {
                when (type) {
                    3 -> {
                        img.loadCircle(bean.image!!)
                        tvName.text = bean.name
                        tvTime.text = bean.createdate
                        tvLikeCount.text = bean.clickcount
                        tvContent.text = bean.content
                        tvLikeCount.isSelected = bean.ifclick == "1"
                        when (bean.type) {
                            "1" -> tvRole.text = "学生"
                            "2" -> tvRole.text = "老师"
                            "3" -> tvRole.text = "家长"
                        }
                    }

                    else -> {
                        tvLikeCount.isSelected = bean.ifclick == "1"

                        tvTime.text = bean.createdate
                        tvLikeCount.text = bean.clickcount
                        tvContent.text = bean.content
                        if (bean.ifniming == "2") {
//                            img.setBackgroundResource(com.lixinkeji.base.R.drawable.mx_common_divider)
                            img.loadCircle("")
                            tvName.text = "匿名用户"
                            tvRole.gone()
                        } else {
                            img.loadCircle(bean.image!!)
                            tvName.text = bean.name
                            tvRole.visible()
                        }
                        when (bean.type) {
                            "1" -> tvRole.text = "学生"
                            "2" -> tvRole.text = "老师"
                            "3" -> tvRole.text = "家长"
                        }
                    }
                }


            }
        }
        R.id.tvLikeCount.onClick {
            if ((models?.get(modelPosition) as DataListBean).ifclick == "1") (models?.get(
                modelPosition
            ) as DataListBean).ifclick = "2"
            else (models?.get(modelPosition) as DataListBean).ifclick = "1"
            if ((models?.get(modelPosition) as DataListBean).ifclick == "1") {
                (models?.get(modelPosition) as DataListBean).clickcount =
                    ((models?.get(modelPosition) as DataListBean).clickcount!!.toInt() + 1).toString()
            } else {
                (models?.get(modelPosition) as DataListBean).clickcount =
                    ((models?.get(modelPosition) as DataListBean).clickcount!!.toInt() - 1).toString()
            }
            scopeNetLife {
                when (type) {
                    1 -> addLikeComment((models?.get(modelPosition) as DataListBean).id!!)
                    2 -> clickrenwu((models?.get(modelPosition) as DataListBean).id!!)
                }

            }
            notifyDataSetChanged()
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.database(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_database)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemDatabaseBinding>().apply {
                tvName.text = bean.title
                tvFolderNum.text = bean.filecount + "个文件"
                tvTime.text = bean.createdate
                tvFolderWeight.text = bean.size + "Kb"
                imgSelect.isSelected = checkedPosition.contains(modelPosition)
            }
        }
        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }

        R.id.imgSelect.onClick {
            setChecked(modelPosition, !checkedPosition.contains(modelPosition))
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.databaseDialog(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_database)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemDatabaseBinding>().apply {
                rl.background = context.getDrawable(R.drawable.bg_rect_f7f8fa_11dp)
                tvName.text = bean.title
                tvFolderNum.text = bean.filecount + "个文件"
                tvTime.text = bean.createdate
                tvFolderWeight.text = bean.size
                imgSelect.isSelected = checkedPosition.contains(modelPosition)
            }
        }
        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }

        R.id.imgSelect.onClick {
            setChecked(modelPosition, !checkedPosition.contains(modelPosition))
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.databaseDetail(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_database_detail)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemDatabaseDetailBinding>().apply {
                tvName.text = bean.title
                img.loadRound(bean.url!!, 10, true)
                tvTime.text = bean.createdate
                tvFolderWeight.text = bean.size + "Kb"
                imgSelect.isSelected = checkedPosition.contains(modelPosition)

            }
        }

        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }

        R.id.imgSelect.onClick {
            setChecked(modelPosition, !checkedPosition.contains(modelPosition))
        }

        R.id.rl.onClick {

//            val urlList = ArrayList<String>()
//            urlList.add(getModel<DataListBean>(modelPosition).url!!)
//            getBinding<ItemDatabaseDetailBinding>().img.preview(context as Activity, 0, urlList)
            context.start(DatabaseDetailPreviewAct::class.java) {
                putExtra("dataListBean", getModel<DataListBean>(modelPosition))
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.answer(): BindingAdapter {
    return linear(HORIZONTAL).setup {
        addType<DataListBean>(R.layout.item_answer)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemAnswerBinding>().apply {
                tvQuestionNo.text = (modelPosition + 1).toString()
                when (bean.type) {
                    "3" -> tvQuestionNo.background = context.getDrawable(R.drawable.oval_answered)
                    else -> {
                        when (bean.ifright) {
                            "1" -> {
                                if (bean.right == bean.answer) {
                                    tvQuestionNo.background =
                                        context.getDrawable(R.drawable.oval_answer_yes)
                                } else {
                                    tvQuestionNo.background =
                                        context.getDrawable(R.drawable.oval_answer_no)
                                }
                            }

                            else -> {
                                tvQuestionNo.background =
                                    context.getDrawable(R.drawable.oval_answered)
                            }
                        }
                    }
                }

            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.weiduList(): BindingAdapter {
    return linear(HORIZONTAL).setup {
        addType<WeiduBean>(R.layout.item_weidu)
        singleMode = true
        onBind {
            val bean = getModel<WeiduBean>()
            getBinding<ItemWeiduBinding>().apply {
                tvName.text = bean.name
                tvScore.text = bean.totalsource
            }
        }
    }
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.moreChoiceQuestionAnswer(rightAnswer: String): BindingAdapter {
    return linear().setup {
        addType<Options>(R.layout.item_choice_question_answer)
        singleMode = false
        onBind {
            val bean = getModel<Options>()
            getBinding<ItemChoiceQuestionAnswerBinding>().apply {

                if (rightAnswer.contains(bean.option!!) || checkedPosition.contains(modelPosition)) {
                    rl.setRoundRectBg(Color.parseColor("#E5FFFE"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#009B93"))
                } else {
                    rl.setRoundRectBg(Color.parseColor("#F9F9F9"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#333333"))
                }
                tvContent.text = bean.option + ":" + bean.title
            }
        }

        onChecked { _, _, _ ->
            notifyDataSetChanged()
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.choiceQuestionAnswer(rightAnswer: String): BindingAdapter {
    return linear().setup {
        addType<Options>(R.layout.item_choice_question_answer)
        singleMode = true
        onBind {
            val bean = getModel<Options>()
            getBinding<ItemChoiceQuestionAnswerBinding>().apply {

                if (bean.option == rightAnswer || bean.isRightKey == true) {
                    rl.setRoundRectBg(Color.parseColor("#E5FFFE"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#009B93"))
                } else {
                    rl.setRoundRectBg(Color.parseColor("#F9F9F9"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#333333"))
                }
                tvContent.text = bean.option + ":" + bean.title
                if (bean.image.isNullOrEmpty()) {
                    imgAnswer.gone()
                } else {
                    imgAnswer.loadRound(bean.image!!, 10, true)
                    imgAnswer.visible()
                }
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.choiceMoreQuestionAnswer(rightAnswer: String): BindingAdapter {
    return linear().setup {
        addType<Options>(R.layout.item_choice_question_answer)
        singleMode = true
        onBind {
            val bean = getModel<Options>()
            getBinding<ItemChoiceQuestionAnswerBinding>().apply {

                if (rightAnswer.contains(bean.option!!)) {
                    rl.setRoundRectBg(Color.parseColor("#E5FFFE"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#009B93"))
                } else {
                    rl.setRoundRectBg(Color.parseColor("#F9F9F9"), context.dp2px(5f).toInt())
                    tvContent.setTextColor(Color.parseColor("#333333"))
                }
                tvContent.text = bean.option + ":" + bean.title
                if (bean.image.isNullOrEmpty()) {
                    imgAnswer.gone()
                } else {
                    imgAnswer.loadRound(bean.image!!, 10, true)
                    imgAnswer.visible()
                }
            }
        }
    }
}


fun GridImageView.selectImages(
    selectList: ArrayList<LocalMedia>,
    activity: Activity,
    hasSelectType: Int = 0,
    maxSelect: Int,
    type: Int = 0,
    isDialog: Boolean = false,
    onClick: () -> Unit = {},
    callback: (ArrayList<LocalMedia>) -> Unit
) {
    val lastImageList = ArrayList<ImageItem>()
    val lastImageList1 = ArrayList<LocalMedia>()
    val imageList = ArrayList<ImageItem>()
    val imageList1 = ArrayList<LocalMedia>()
    imageList.add(ImageItem())
    imageList1.add(LocalMedia())
    setIsAuto(false)
    var canVideo = false
    setAdapter(object : XBaseAdapter() {
        override val count: Int
            get() = imageList1.size

        @SuppressLint("UseCompatLoadingForDrawables", "SetTextI18n")
        override fun getView(position: Int, parent: ViewGroup?): View? {
            val view =
                LayoutInflater.from(context).inflate(R.layout.select_image_item, parent, false)
            val imageView = view.findViewById<ImageView>(R.id.image)
            val removeView = view.findViewById<ImageView>(R.id.remove_image)
            val timeView = view.findViewById<TextView>(R.id.time)
            imageView.setBackgroundResource(
                R.drawable.icon_add_img
            )

            imageView.onClick {
                if (lastImageList1.size != 0) {
                    if (imageList1[position].realPath != null) {
                        PictureSelector.create(activity).openPreview()
                            .setImageEngine(GlideEngine.createGlideEngine())
                            .setExternalPreviewEventListener(object :
                                OnExternalPreviewEventListener {
                                override fun onPreviewDelete(position: Int) {}
                                override fun onLongPressDownload(
                                    context: Context?, media: LocalMedia?
                                ): Boolean {
                                    return false
                                }
                            }).startActivityPreview(position, true, lastImageList1)
                    } else if (imageList1[position].realPath == null) {//已选图片
                        canVideo = false
                        context.pictureSelect(
                            selectList,
                            activity,
                            canVideo = canVideo,
                            maxCount = maxSelect,
                            lastImageList = lastImageList
                        ) {
                            lastImageList1.clear()
                            lastImageList1.addAll(it)
                            imageList1.clear()
                            imageList1.addAll(it)
                            callback(imageList1)
                            if (!canVideo && imageList1.size < maxSelect || imageList1.size == 0) {
                                imageList1.add(LocalMedia())
                            }
                            sendEvent(1, "img_type")
                            notifyDataSetChanged()
                        }

                    }
                } else if (hasSelectType == 1) {
                    canVideo = false
                    context.pictureSelect(
                        selectList,
                        activity,
                        canVideo = canVideo,
                        maxCount = maxSelect,
                        lastImageList = lastImageList
                    ) {
                        for (i in 0 until it.size) {
                            if (!FileUtil.isExist(it[i].realPath)) {
                                it[i].realPath =
                                    "/storage/emulated/0/Pictures/" + it[i].realPath.substring(
                                        it[i].realPath.lastIndexOf("/") + 1
                                    )
                            }
                        }
                        lastImageList1.clear()
                        lastImageList1.addAll(it)
                        imageList1.clear()
                        imageList1.addAll(it)
                        callback(imageList1)
                        if (!canVideo && imageList1.size < maxSelect || imageList1.size == 0) {
                            imageList1.add(LocalMedia())
                        }
                        sendEvent(1, "img_type")
                        notifyDataSetChanged()
                    }
                } else if (hasSelectType == 2) {
                    canVideo = true
                    lastImageList1.clear()
                    imageList1.clear()
                    context.pictureSelect(
                        selectList,
                        activity,
                        canVideo = canVideo,
                        maxCount = 1,
                        lastImageList = lastImageList
                    ) {
                        lastImageList1.clear()
                        imageList1.clear()
                        if (FileUtil.isExist(it[0].realPath)) {
                            lastImageList1.addAll(it)
                            imageList1.addAll(it)
                        } else {
                            it[0].path = "/storage/emulated/0/Movies/" + it[0].path.substring(
                                it[0].path.lastIndexOf("/") + 1
                            )
                            lastImageList1.addAll(it)
                            imageList1.addAll(it)
                        }
                        callback(imageList1)
                        sendEvent(2, "img_type")
                        notifyDataSetChanged()
                    }
                } else if (lastImageList1.size == 0 && hasSelectType == 0) {
                    if (imageList1.size == 0 || imageList1[position].realPath.isNullOrEmpty()) {
                        if (isDialog) {
                            onClick()
                            context.bottomDialog("图片", two = "视频", onOne = {
                                canVideo = false
                                context.pictureSelect(
                                    selectList,
                                    activity,
                                    canVideo = canVideo,
                                    maxCount = maxSelect,
                                    lastImageList = lastImageList
                                ) {
                                    for (i in 0 until it.size) {
                                        if (!FileUtil.isExist(it[i].realPath)) {
                                            it[i].realPath =
                                                "/storage/emulated/0/Pictures/" + it[i].realPath.substring(
                                                    it[i].realPath.lastIndexOf("/") + 1
                                                )
                                        }
                                    }
                                    lastImageList1.clear()
                                    lastImageList1.addAll(it)
                                    imageList1.clear()
                                    imageList1.addAll(it)
                                    callback(imageList1)
                                    if (!canVideo && imageList1.size < maxSelect || imageList1.size == 0) {
                                        imageList1.add(LocalMedia())
                                    }
                                    sendEvent(1, "img_type")
                                    notifyDataSetChanged()
                                }
                            }, onTwo = {
                                canVideo = true
                                lastImageList1.clear()
                                imageList1.clear()
                                context.pictureSelect(
                                    selectList,
                                    activity,
                                    canVideo = canVideo,
                                    maxCount = 1,
                                    lastImageList = lastImageList
                                ) {
                                    lastImageList1.clear()
                                    imageList1.clear()
                                    if (FileUtil.isExist(it[0].realPath)) {
                                        lastImageList1.addAll(it)
                                        imageList1.addAll(it)
                                    } else {
                                        it[0].path =
                                            "/storage/emulated/0/Movies/" + it[0].path.substring(
                                                it[0].path.lastIndexOf("/") + 1
                                            )
                                        lastImageList1.addAll(it)
                                        imageList1.addAll(it)
                                    }
                                    callback(imageList1)
                                    sendEvent(2, "img_type")
                                    notifyDataSetChanged()
                                }
                            })

                        } else {
                            context.pictureSelect(
                                selectList,
                                activity,
                                canVideo = canVideo,
                                maxCount = maxSelect,
                                lastImageList = lastImageList
                            ) {
                                lastImageList1.clear()
                                lastImageList1.addAll(it)
                                imageList1.clear()
                                imageList1.addAll(it)
                                callback(imageList1)
                                if (!canVideo && imageList.size < maxSelect || imageList.size == 0) {
                                    imageList1.add(LocalMedia())
                                }
                                notifyDataSetChanged()
                            }
                        }
                    } else {
                        val image = ArrayList<String>()
                        imageList.forEach {
                            if (!it.path.isNullOrEmpty()) {
                                image.add(it.path)
                            }
                        }
                        imageView.preview(context as Activity, position, image)
                    }
                }
            }
            removeView.onClick {
                lastImageList1.removeAt(position)
                imageList1.clear()
                imageList1.addAll(lastImageList1)
                callback(imageList1)
                if (imageList1.size < maxSelect) {
                    imageList1.add(LocalMedia())
                }
                notifyDataSetChanged()
            }


            val path = imageList1[position].realPath
            if (path.isNullOrEmpty()) {
                imageView.scaleType = ImageView.ScaleType.CENTER
                imageView.setImageResource(
                    R.drawable.icon_add_img
                )
                removeView.gone()
                timeView.gone()
            } else {
                removeView.visible()
                timeView.applyVisible(canVideo)
                if (canVideo) {
                    //设置视频时长
                    var duration = imageList1[position].duration
                    var minute = ""
                    var second = ""
                    minute = if (duration / 1000 / 60 < 10) {
                        "0" + duration / 1000 / 60
                    } else {
                        (duration / 1000 / 60).toString()
                    }
                    second = if (duration / 1000 % 60 < 10) {
                        "0" + duration / 1000 % 60
                    } else {
                        (duration / 1000 % 60).toString()
                    }
                    timeView.visible()
                    timeView.text = "$minute:$second"
                } else {
                    timeView.gone()
                }
                imageView.scaleType = ImageView.ScaleType.CENTER_CROP

                //解决图片旋转问题
                var myBitmap: Bitmap
                if (canVideo) {
                    myBitmap = getBitmapFormUrl(path)!!
                } else {
                    myBitmap = BitmapFactory.decodeFile(path)
                }

                try {
                    val exif = ExifInterface(path)
                    val orientation: Int = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1)
                    val matrix = Matrix()
                    if (orientation == 6) {
                        matrix.postRotate(90F)
                    } else if (orientation == 3) {
                        matrix.postRotate(180F)
                    } else if (orientation == 8) {
                        matrix.postRotate(270F)
                    }
                    myBitmap = Bitmap.createBitmap(
                        myBitmap, 0, 0, myBitmap.width, myBitmap.height, matrix, true
                    ) // rotating bitmap
                } catch (e: Exception) {
                }
                imageView.setImageBitmap(myBitmap)
            }
            return view
        }
    })
}

fun getBitmapFormUrl(url: String?): Bitmap? {
    val retriever = MediaMetadataRetriever()
    retriever.setDataSource(url)
    val bitmap = retriever.frameAtTime
    retriever.release()
    return bitmap
}


@SuppressLint("NotifyDataSetChanged")
fun RecyclerView.groupScore(): BindingAdapter {
    return linear().setup {
        addType<DataListBean>(R.layout.item_group_score)
        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            getBinding<ItemGroupScoreBinding>().apply {

                when (bean.ifzudui) {
                    "1" -> {
                        tvGroupName.text = "组别：" + bean.groupname
                        tvGroupContent.text = "组员：" + bean.groupstudent
                        tvGroupContent.visible()
                        tvTotalScore.text = "总得分：" + bean.totaldefen
                    }

                    "2" -> {
                        tvGroupName.text = "姓名：" + bean.groupname
                        tvTotalScore.text = "总得分：" + bean.totaldefen
                        tvGroupContent.gone()
                    }
                }

                tvCourseName.text = "所属课程：" + bean.smalltitle

//                var idList = ArrayList<String>()
//                if (context.allGroupIdList.isNotEmpty()) {
//                    idList = GSON.fromJson(
//                        context.allGroupIdList,
//                        ArrayList<String>().javaClass
//                    )
//                    if (!idList.contains(bean.id)) {
//                        for (i in 0 until bean.weidulist!!.size) {
//                            radarChartView.insertType(
//                                bean.weidulist[i].name,
//                                bean.weidulist[i].totalsource?.toDouble()!!.toInt(),
//                                bean.weidulist[i].nums?.toDouble()!!.toInt(),
//                            )
//                        }
//
//                        val config = RadarChartView.Config().setMaxLevel(5).setCenterPointRadius(5)
//                            .setChartWidget(0.8f).setFillColor(-0xd97beb).setSecondFillColor(-0x32d9da)
//                            .setValueLineSize(1).setValuePointRadius(5).setBackgroundColor(-0x7767a9eb)
//                            .setTextColor(-0x7767a9eb).setTextSize(40).setCanScroll(true)
//                            .setCanFling(false).setValueBackgroundAlpha(0.2f).setTextPosition(1.1f)
//                            .setPointRadius(2)
//                        radarChartView.setConfig(config)
//
//                        idList.add(bean.id!!)
//                        context.allGroupIdList = GSON.toJson(idList)
//                    }
//                } else {
//                    for (i in 0 until bean.weidulist!!.size) {
//                        radarChartView.insertType(
//                            bean.weidulist[i].name,
//                            bean.weidulist[i].totalsource?.toDouble()!!.toInt(),
//                            bean.weidulist[i].nums?.toDouble()!!.toInt(),
//                        )
//                    }
//
//                    val config = RadarChartView.Config().setMaxLevel(5).setCenterPointRadius(5)
//                        .setChartWidget(0.8f).setFillColor(-0xd97beb).setSecondFillColor(-0x32d9da)
//                        .setValueLineSize(1).setValuePointRadius(5).setBackgroundColor(-0x7767a9eb)
//                        .setTextColor(-0x7767a9eb).setTextSize(40).setCanScroll(false)
//                        .setCanFling(false).setValueBackgroundAlpha(0.2f).setTextPosition(1.1f)
//                        .setPointRadius(2)
//                    radarChartView.setConfig(config)
//
//                    idList.add(bean.id!!)
//                    context.allGroupIdList = GSON.toJson(idList)
//                }

                if (bean.weidulist == null || bean.weidulist.size == 0) {
                    radarChartView.gone()
                } else {
                    radarChartView.visible()
                    if (radarChartView.tag == null) {
                        radarChartView.tag = modelPosition
                        for (i in 0 until bean.weidulist!!.size) {
                            radarChartView.insertType(
                                bean.weidulist[i].name + "(" + bean.weidulist[i].nums?.toDouble()!!
                                    .toInt() + "分)",
                                bean.weidulist[i].nums?.toDouble()!!.toInt(),
                                bean.weidulist[i].totalsource?.toDouble()!!.toInt()
                            )
                        }

                        val config = RadarChartView.Config().setMaxLevel(4).setCenterPointRadius(2)
                            .setChartWidget(0.6f).setFillColor(-0xd97beb)
                            .setSecondFillColor(-0x32d9da)
                            .setValueLineSize(2).setValuePointRadius(5)
                            .setBackgroundColor(-0x7767a9eb)
                            .setTextColor(-0x7767a9eb).setTextSize(40).setCanScroll(false)
                            .setCanFling(false).setValueBackgroundAlpha(0.2f).setTextPosition(1.1f)
                            .setPointRadius(2)
                        radarChartView.setConfig(config)
                    }
                }
            }
        }

        R.id.rl.onClick {
            context.start(TaskDetailAct::class.java) {
                putExtra("groupid", (getModel(modelPosition) as DataListBean).cid)
            }
        }
    }
}

@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
fun RecyclerView.myClassStu(): BindingAdapter {
    return linear().setup {
        when (context.user_role) {
            1 -> {
                addType<DataListBean>(R.layout.item_my_class)
            }

            2 -> {
                addType<DataListBean>(R.layout.item_my_class)
            }

            3 -> {
                addType<DataListBean>(R.layout.item_my_class_teacher)
            }
        }



        singleMode = true
        onBind {
            val bean = getModel<DataListBean>()
            when (context.user_role) {
                1 -> {
                    getBinding<ItemMyClassBinding>().apply {
                        if (bean.image != null) img.loadRound(bean.image!!, 10, true)
                        tvTitle.text = bean.title
                        tvTime.text = "创建时间" + bean.createdate
                        tvJoinCount.text = bean.studentcount + "人加入"
                        tvName.text = bean.teachername
                        headImg.loadCircle(bean.teacherimage!!)

                    }
                }

                2 -> {
                    getBinding<ItemMyClassBinding>().apply {
                        if (bean.image != null) img.loadRound(bean.image!!, 10, true)
                        tvTitle.text = bean.title
                        tvTime.text = "加入时间：" + bean.createdate?.substring(0, 10)
                        tvJoinCount.text = bean.studentcount + "人加入"
                        tvName.text = "创建人：" + bean.teachername
                        headImg.loadCircle(bean.teacherimage!!)
                    }
                }

                3 -> {
                    getBinding<ItemMyClassTeacherBinding>().apply {
                        tvTitle.text = bean.title + "  访问码：" + bean.code
                        tvTime.text =
                            "学生数：" + bean.studentcount + " 未加入" + bean.weijiarucount + " 教师数：" + bean.teachercount
                        if (bean.daipiyuecount == "0" || bean.daipiyuecount.isNullOrEmpty()) {
                            tvMessageCount.gone()
                        } else {
                            tvMessageCount.visible()
                            tvMessageCount.text = bean.daipiyuecount
                        }

                    }
                }

            }

        }
        R.id.tvSendNotice.onClick {
            context.start(ReleaseNoticeAct::class.java) {
                putExtra("classid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
        R.id.tvClassStudent.onClick {
            context.start(ClassStudentAct::class.java) {
                putExtra("classid", (models?.get(modelPosition) as DataListBean).id)
                putExtra("type", 1)
            }
        }
        R.id.tvReview.onClick {
            context.start(CourseReviewAct::class.java) {
                putExtra("classid", (models?.get(modelPosition) as DataListBean).id)
            }
        }
        R.id.tvClassTeacher.onClick {
            context.start(ClassStudentAct::class.java) {
                putExtra("classid", (models?.get(modelPosition) as DataListBean).id)
                putExtra("type", 2)
            }
        }
    }
}

